
package com.zy.ems.common.jedis;

import org.apache.commons.lang3.StringUtils;

import com.zy.ems.common.exception.BaseErrorStatus;
import com.zy.ems.common.exception.BusinessException;

/**
 * Redis存储key定义。
 * 
 * @author Luffy
 * 
 */
public class RedisKey {
    /**
     * 频道所有模块key前缀（home_channelAll_${channelID}）
     */
    private static final String HOME_CHANNELALL_ = "home_channelAll_";

    /**
     * 模块Key前缀（home_${channelID}_${moduleID}）
     */
    private static final String HOME_ = "home_";

    /**
     * 子分类前缀（home_cate_${parentCateID}）
     */
    private static final String HOME_CATE_ = "home_cate_";

    /**
     * 首页频道导航栏
     */
    public static final String HOME_CHANNELNAVBAR = "home_channelNavBar";

    /**
     * 轮播
     */
    public static final String HOME_TOPLST = "home_toplst";

    /**
     * 通知消息
     */
    public static final String HOME_NOTICE = "home_notice";

    /**
     * 热门搜索
     */
    public static final String HOME_HOTSEARCHWORDS = "home_hotSearchWords";

    /**
     * 一级分类
     */
    public static final String HOME_CATE_LEVEL1 = "home_cate_level1";

    /**
     * 品牌
     */
    public static final String HOME_HOT_BRAND = "home_hot_brand";

    /**
     * 商品价格缓存key
     */
    public static final String PRICE_STOCK_SPEC = "priceStock_spec_";

    public static final String PRICE_STOCK_PROD = "priceStock_prod_";

    /**
     * 获取指定频道所有模块key。
     * 
     * @param channelId
     * @return
     */
    public static String getChannelModulesKey(String channelId) {
        if (StringUtils.isBlank(channelId)) {
            throw new BusinessException(BaseErrorStatus.sys_008);
        }
        return HOME_CHANNELALL_.concat(channelId);
    }

    /**
     * 获取指定频道的指定模块key。
     * 
     * @param channelId
     * @param moduleId
     * @return
     */
    public static String getModuleKey(String channelId, String moduleId) {
        if (StringUtils.isBlank(channelId) || StringUtils.isBlank(moduleId)) {
            throw new BusinessException(BaseErrorStatus.sys_008);
        }
        return HOME_.concat(channelId).concat("_").concat(moduleId);
    }

    /**
     * 获取子分类key。
     * 
     * @param parentId
     * @return
     */
    public static String getSubCategoryKey(String parentId) {
        if (StringUtils.isBlank(parentId)) {
            throw new BusinessException(BaseErrorStatus.sys_008);
        }
        return HOME_CATE_.concat(parentId);
    }

}
